#!/usr/local/bin/perl
# Copyright (c) 2000-2006 ActiveState Software Inc.
# See the file LICENSE.txt for licensing information.

use Cwd;

Import(
    "cons",
    "buildFlavour",
    "supportDir",
    "sysdllsDir",
    "platform",
    "architecture",
    "buildType",
    "komodoDevDir",
    "mozBin",
    "productType",
    "version",
    "komodoPythonUtilsDir",
    "ranRegxpcomStateFileName",
    "komodoPythonUtilsDir",
);


sub getPrebuiltDirectory {
    my $endpath = shift;
    my $myBuildType = shift || $buildType;
    if ($platform eq 'win') {
        return cwd()."/prebuilt/win/$myBuildType/$endpath";
    }
    if ($platform eq 'darwin') {
        return cwd()."/prebuilt/macosx/$myBuildType/$endpath";
    }
    if (-e cwd()."/prebuilt/$platform-$architecture/$myBuildType/$endpath") {
        return cwd()."/prebuilt/$platform-$architecture/$myBuildType/$endpath";
    }
    return cwd()."/prebuilt/$platform/$myBuildType/$endpath";
}

# Hack default user-skins.rdf (see bug 23047).
# - This is only really required on Linux and, besides, it breaks the
#   Windows build with this:
#       cons.pl: error in file "prebuilt\Conscript" (cons.pl: attempt to build install\release\user_withmoz\INSTALLDIR\Mozilla\chrome\user-skins.rdf twice, in different ways!)
# XXX Trent to see if necessary on darwin
if ($platform ne "win" && $platform ne "darwin") {
    $cons->Install("$mozBin/chrome", "all/chrome/user-skins.rdf");
}


# Install Mac OS X color picker binary.
if ($platform eq "darwin") {
    $sourcedir = getPrebuiltDirectory("colorpicker/osx_colorpicker");
    $cons->Install("$supportDir/colorpicker", $sourcedir);
}
